package router

import (
	"github.com/gin-gonic/gin"
	"starry_sky/api/handler"
	"starry_sky/internal/middleware/http-middleware"
)

func systemRegister(r *gin.Engine) {
	noAuth := r.Group("/admin-api")
	{
		auth := noAuth.Group("/auth")
		{
			auth.POST("/login", handler.AuthHandler)
			auth.POST("/refresh-token", handler.RefreshToken)
		}
	}
	adminApi := r.Group("/admin-api", http_middleware.JWTAuthMiddleware())
	{
		system := adminApi.Group("/system")
		{

			auth := system.Group("/auth")
			{
				auth.GET("/get-permission-info", handler.GetUserInfo)
			}
			menu := system.Group("/menu")
			{
				menu.POST("/create", handler.CreatePermission)
				menu.PUT("/update", handler.UpdatePermission)
				menu.DELETE("/delete", handler.DeletePermission)
				menu.GET("/list", handler.FindAllPermission)
				menu.GET("/get", handler.FindPermissionById)
			}
			permission := system.Group("/permission")
			{
				permission.POST("/assign-user-role", handler.BindUserAndRole)
				permission.POST("/assign-role-menu", handler.BindRoleAndPermission)
			}
			role := system.Group("/role")
			{
				role.POST("/create", handler.CreateRole)
				role.PUT("/update", handler.UpdateRole)
				role.PUT("/update-status", handler.UpdateRoleStatus)
				role.GET("/page", handler.PageRole)
				role.GET("/get", handler.FindRoleById)
				role.DELETE("/delete", handler.DeleteRole)
				role.GET("/simple-list", handler.AllRoleList)
			}
			user := system.Group("/user")
			{
				user.POST("/create", handler.CreateUser)
				user.PUT("/update", handler.UpdateUser)
				user.PUT("/update-status", handler.UpdateUserStatus)
				user.PUT("/update-password", handler.UpdateUserPassword)
				user.GET("/page", handler.PageUser)
				user.GET("/get", handler.FindUserById)
				user.DELETE("/delete", handler.DeleteUser)
			}
			dictType := system.Group("dict-type")
			{
				dictType.POST("/create", handler.CreateDictType)
				dictType.PUT("/update", handler.UpdateDictType)
				dictType.DELETE("/delete", handler.DeleteDictType)
				dictType.GET("/page", handler.PageDictType)
				dictType.GET("/get", handler.FindDictTypeById)
			}
			dictData := system.Group("dict-data")
			{
				dictData.POST("/create", handler.CreateDictData)
				dictData.PUT("/update", handler.UpdateDictData)
				dictData.DELETE("/delete", handler.DeleteDictData)
				dictData.GET("/page", handler.PageDictData)
				dictData.GET("/get", handler.FindDictDataById)
			}
		}

	}
}
